package com.bjl.controller;

import com.alibaba.fastjson.JSONObject;
import com.bjl.service.DealService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import orm.base.Ex.BaseControllerEx;

import java.util.Map;

/**
 * Created by ashin on 2017/11/22.
 */
@Controller
@Scope("prototype")
@RequestMapping("/deal")
public class DealController extends BaseControllerEx {

    @Autowired
    DealService dealService;

    @Override
    protected void init() {
        super.init(dealService);
    }

    /**
     * 增加积分
     *
     * @param map
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/doRecharge", method = RequestMethod.POST)
    public JSONObject doRecharge(@RequestParam Map map) throws Exception {
        return dealService.recharge(map, session);
    }

    /**
     * 积分兑换核销
     *
     * @param map
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/doConsume", method = RequestMethod.POST)
    public JSONObject doConsume(@RequestParam Map map) throws Exception {
        return dealService.consume(map, session);
    }

    /**
     * 投注消耗积分
     *
     * @param map
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/doBet", method = RequestMethod.POST)
    public JSONObject doBet(@RequestParam Map map) throws Exception {
        return dealService.bet(map, session);
    }

    @Override
    protected JSONObject doQuery(@RequestParam Map map) throws Exception {
        return dealService.query(map, session);
    }

    /**
     * 查询用户历史积分消费记录
     *
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/doGetDealAccount", method = RequestMethod.POST)
    public JSONObject doGetDealAccount(@RequestParam Map map) throws Exception {
        return dealService.dealAccount(map, session);
    }

    /**
     * 查询用户积分出入总额
     *
     * @param map
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/doGetUserTotal", method = RequestMethod.POST)
    public JSONObject doGetUserTotal(@RequestParam Map map) throws Exception {
        return dealService.getUserTotal(map, session);
    }

    /**
     * 导出用户积分出入总额
     * @param map
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/doExportUserTotalExcel", method = RequestMethod.POST)
    public void doExportUserTotalExcel(@RequestParam Map map) throws Exception {
        dealService.exportUserTotalExcel(map,session,response);
    }

    /**
     * 获得单个用户积分详情
     *
     * @param map
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/doGetSingleUserTotal", method = RequestMethod.POST)
    public JSONObject doGetSingleUserTotal(@RequestParam Map map) throws Exception {
        return dealService.getSingleUserTotal(map, session);
    }

    /**
     * 获得单个用户积分详情-后台管理
     *
     * @param map
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/doGetSingleUserTotalByAdmin", method = RequestMethod.POST)
    public JSONObject doGetSingleUserTotalByAdmin(@RequestParam Map map) throws Exception {
        return dealService.getSingleUserTotalByAdmin(map, session);
    }

    /**
     * 用户每小时活跃度
     *
     * @param map
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/doQueryUserCountByPerHour", method = RequestMethod.POST)
    public JSONObject doQueryUserCountByPerHour(@RequestParam Map map) throws Exception {
        return dealService.queryUserCountByPerHour(map, session);
    }

    /**
     * 导出用户每小时活跃度
     *
     * @param map
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/doExportUserCountByPerHour", method = RequestMethod.POST)
    public void doExportUserCountByPerHour(@RequestParam Map map) throws Exception {
        dealService.exportUserCountByPerHour(map, session,response);
    }

    /**
     * 查询用户所有投注信息(按照房间查询)
     *
     * @param map
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/doQueryUserIntegralRoom", method = RequestMethod.POST)
    public JSONObject doQueryUserIntegralRoom(@RequestParam Map map) throws Exception {
        return dealService.queryUserIntegralRoom(map, session);
    }

    /**
     * 查询用户所有投注信息(按照房间查询)
     *
     * @param map
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/doQueryAllIntegralRoom", method = RequestMethod.POST)
    public JSONObject doQueryAllIntegralRoom(@RequestParam Map map) throws Exception {
        return dealService.queryAllIntegralRoom(map, session);
    }

    /**
     * 查询当前局数的所有积分总和信息
     *
     * @param map
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/doQuerySingleIssueAccount", method = RequestMethod.POST)
    public JSONObject doQuerySingleIssueAccount(@RequestParam Map map) throws Exception {
        return dealService.querySingleIssueAccount(map, session);
    }

    /**
     * 验证是否中奖
     *
     * @param map
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/doCheckIsWin", method = RequestMethod.POST)
    public JSONObject doCheckIsWin(@RequestParam Map map) throws Exception {
        return dealService.checkIsWin(map, session);
    }

    /**
     * 查询数据总览信息
     * @param map
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/doQueryAllDataInfo", method = RequestMethod.POST)
    public JSONObject doQueryAllDataInfo(@RequestParam Map map) throws Exception{
        return dealService.queryAllDataInfo(map, session);
    }

    /**
     * 房间概况
     * @param map
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/doQueryRoomsDataInfo", method = RequestMethod.POST)
    public JSONObject doQueryRoomsDataInfo(@RequestParam Map map) throws Exception{
        return dealService.queryRoomsDataInfo(map, session);
    }

    /**
     * 查询用户概况
     * @param map
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/doQueryUserDataInfo", method = RequestMethod.POST)
    public JSONObject doQueryUserDataInfo(@RequestParam Map map) throws Exception{
        return dealService.queryUserDataInfo(map, session);
    }

    /**
     * 导出查询数据总览信息
     * @param map
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/doExportAllDataInfo", method = RequestMethod.POST)
    public void doExportAllDataInfo(@RequestParam Map map) throws Exception{
        dealService.exportAllDataInfo(map, session,response);
    }

    /**
     * 导出房间概况
     * @param map
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/doExportRoomsDataInfo", method = RequestMethod.POST)
    public void doExportRoomsDataInfo(@RequestParam Map map) throws Exception{
        dealService.exportRoomsDataInfo(map, session,response);
    }

    /**
     * 导出查询用户概况
     * @param map
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/doExportUserDataInfo", method = RequestMethod.POST)
    public void doExportUserDataInfo(@RequestParam Map map) throws Exception{
        dealService.exportUserDataInfo(map, session,response);
    }


}
